﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${pageContext.request.contextPath}/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<%@ include file="base.jsp" %>
<script src="${pageContext.request.contextPath}/js/jquery.min.js" type="text/javascript"></script>   
<script src="${pageContext.request.contextPath}/js/base.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerGrid.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerForm.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDateEditor.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerToolBar.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerComboBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerCheckBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerRadio.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerSpinner.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTextBox.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/inject.js" type="text/javascript"></script> 
<script src="${pageContext.request.contextPath}/js/ligerPopupEdit.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDialog.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerDrag.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerTip.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/ligerResizable.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/jquery.metadata.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/messages_cn.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/ligerUiCommon.js" type="text/javascript"></script>  
<script src="${pageContext.request.contextPath}/js/js/ddxx.js" type="text/javascript"></script>  
<script src="${pageContext.request.contextPath}/js/common/ajax.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/js/common/dateFormateUtil.js" type="text/javascript"></script>
<script type="text/javascript"> 
	//添加校验
	$(function() {
		addValidate(submitData);
		$("form").ligerForm();
	});
	
		//初始化
		$(function() {
			var obj = eval(${rowJsonStringData});
			if("${isReadOnly}") {//查看
				setView("ddh", obj.ddh);
				setView("khxm", obj.khxm);
				setView("khdh", obj.khdh);
				setView("xsr", obj.xsr);
				setView("ddzj", obj.ddzj);
				setView("ddsj", formatDate(obj.ddsj, "yyyy-MM-dd"));//更新时间
				return;
			}
			//编辑
			if(obj) {
				$("#ddId").val(obj.id);
				$("#ddh").val(obj.ddh);
				$("#ddh").ligerGetTextBoxManager().setDisabled();
				$("#ddh").removeAttr("onblur");
				$("#khxm").val(obj.khxm);
				$("#khdh").val(obj.khdh);
				$("#xsr").val(obj.xsr);
				$("#ddzj").val(obj.ddzj);
				$("#ddsj").val(formatDate(obj.ddsj, "yyyy-MM-dd"));//录入时间
			} else {
				$("#ddsj").val(formatDate(new Date(), "yyyy-MM-dd"));//录入时间
			}
	});
		
	$(function() {
		f_initGrid(contextPath + "/DdglAction?control=getDdxxList", {'ddid':$("#ddId").val()});
	});
	
	//提交商品信息
	function submitData() {
		if($("#error_ddh").html() != null && $("#error_ddh").html().length != 0) {
			return;
		}
		
		var dd = {};
		dd.id = $("#ddId").val();
		dd.ddh = $("#ddh").val();
		dd.khxm = $("#khxm").val();
		dd.khdh = $("#khdh").val();
		dd.xsr = $("#xsr").val();
		dd.ddzj = $("#ddzj").val();
		dd.userid = "${user.id}";
		dd.ddsj = $("#ddsj").val() + " 00:00:00";
		
		var url = "${pageContext.request.contextPath}/DdglAction?control=saveDdxx";
		sendAjaxRequest(url, JSON.stringify(dd), false, function(msg) {
			if(msg.data == "保存成功") {
				$.ligerDialog.success("保存成功");
			} else {
				$.ligerDialog.error(msg.data);
			}
		});
	}
	
	//检测型号是否存在
	function checkDdh() {
		var ddh = $("#ddh").val();
		if(ddh == null || ddh.length == 0) {
			return false;
		}
		var url = "${pageContext.request.contextPath}/DdglAction?control=checkDdh&ddh=" + ddh;
		sendAjaxRequest(url, null, true, function(resData) {
			if(resData.data == "true") {
				$("#error_ddh").html("该订单号已存在，不能输入相同的型号");	
			} else {
				$("#error_ddh").html("");
			}
		});
	}
	
	function setView(id, val) {
		var t = document.getElementById(id);
		while(t.tagName != "TD") {
			t = t.parentNode;
		}
		t.innerHTML = val;
	}
	
	//刷新页面
	function clearInput() {
		location.reload();
	}
</script>
<!--[if IE 6]>
   <script src="js/DD_belatedPNG.js"></script>
   <script>DD_belatedPNG.fix('.xxjbb_5 img');</script>
<![endif]-->
<title></title>
</head>
<style type="text/css">
body{background:#ffffff}
html{_overflow-y:scroll;}
</style>
<body>
<div class="xxjbb_position">
<table width="100%" align="left" cellpadding="0" cellspacing="0">
  <tr>
    <td class="xxjbb_1 xxjbb_3">
     <ul>
       <li class="xxjbb_1_block"><a id="backup" href="${pageContext.request.contextPath}/jsp/ddgl.jsp"><span><<</span>返回</a></li>
       <li><a href="#" onclick="javascript:$('#ddglForm').submit();">保存</a></li>
       <li><a href="#" onclick="clearInput()">重置</a></li>
     </ul>
   </td>
  </tr>
</table>
</div>
<div class="xxjbb_4">
 <form id="ddglForm" name="ddglForm" method="post" >
  <table width="100%" align="left" cellpadding="0" cellspacing="0" class="bjkcxx">
  <input type="hidden" id="ddId" />
      <tr>
        <td class="xxjbb_mc" width="20%"><b>名称</b></td>
        <td class="xxjbb_mccc" width="80%"><b>值</b></td>
      </tr>
      <tr>
        <td class="xxjbb_b">订单号*</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input onblur="checkDdh()" id="ddh" type="text" validate="{required:true}"/></td>
              <td><div id="error_ddh" class="xxjbb_9"></div></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">客户姓名</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input   id="khxm" name="khxm" type="text"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">客户电话*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input   id="khdh" name="khdh" type="text" validate="{required:true,digits:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">销售人</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input   id="xsr" name="xsr" type="text"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_z">订单总价*</td>
        <td class="xxjbb_zzz">
          <table>
            <tr>
              <td><input   id="ddzj" name="ddzj" type="text"  validate="{number:true,required:true}"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="xxjbb_b">订单时间</td>
        <td class="xxjbb_bbb">
          <table>
            <tr>
              <td><input id="ddsj" name="ddsj" type="text" ltype="date"/></td>
            </tr>
          </table>
        </td>
      </tr>
      <!--   <tr>
        <td class="xxjbb_z">附件</td>
        <td class="xxjbb_zzz xxjbb_2 xxjbb_6">
             <ul>
               <li class="xxjbb_1_block"><a href="#">上传</a></li>
             </ul>
        </td>
      </tr>
      -->
    </table>
    </form>
</div>

<div class="xxjbb_8">
 <table width="100%" align="left" cellpadding="0" cellspacing="0" class="bjkcxx" style="margin:10px 0 0 0">
 	  <tr>
   		<td><div id="maingrid"></div></td>
 	  </tr>
    </table>
</div>
</body>
</html>
